import http from '@/api/studentapi'
const state={
    stucourse:{},
    stuhwinfo:{}
};
const actions={
    async getstucourse({commit},name){
        let res=await http.getstucourse(name);
        if(res.status==200){
            commit("GETSTUCOURSE",res.data)
        }
    },
    changestucoursepage({commit},page){
        commit("CHANGESTUCOURSEPAGE",page);
    },
    async getstucoursebyname({commit},data){
        let res=await http.searchstucourse(data);
        if(res.status==200){
            commit("GETSTUCOURSEBYNAME",res.data);
        }
    },
    async getstuhwinfo({commit},name){
        let res=await http.getstuhwinfo(name);
        if(res.status==200){
            commit("GETSTUHWINFO",res.data);
        }
    },
    changestucoursehwpage({commit},page){
        commit("CHANGESTUCOURSEHWPAGE",page)
    },
    async getstucoursehwbyname({commit},data){
        let res=await http.searchstucoursehwbyname(data);
        if(res.status==200){
            commit("GETSTUCOURSEHWBYNAME",res.data)
        }
    }
};
const mutations={
    GETSTUCOURSE(state,data){
        state.stucourse=data;
    },
    CHANGESTUCOURSEPAGE(state,page){
        state.stucourse.currentpage=page;
    },
    GETSTUCOURSEBYNAME(state,data){
        state.stucourse=data;
    },
    GETSTUHWINFO(state,data){
        state.stuhwinfo=data;
    },
    CHANGESTUCOURSEHWPAGE(state,page){
        state.stuhwinfo.currentpage=page;
    },
    GETSTUCOURSEHWBYNAME(state,data){
        state.stuhwinfo=data;
    }
};
const getters={};
export default{
    state,actions,mutations,getters
}